import { v4 as uuidv4 } from 'uuid'
export default (getDetail) => {
  let ticketDetail = {}
  ticketDetail = {
    ...getDetail,
    ...getDetail.SGDivisionOfWorkticket[0]
  }
  const allData = getDetail.cableFirstTicketDetailRO
  delete ticketDetail.SGDivisionOfWorkticket
  // 工作班成员签名默认赋值
  if (ticketDetail.SGTeamMembersSignIn.length === 0 && ticketDetail.partWorkTicketState === 'Execute') {
    ticketDetail.SGTeamMembersSignIn = ticketDetail.SGTeamMembers.map(memberItem => {
      return {
        listID: uuidv4(),
        workTicketID: ticketDetail.partWorkTicketId,
        staffType: memberItem.staffType || '',
        staffId: memberItem.staffId || '',
        staffName: memberItem.staffName || '',
        departmentId: memberItem.deptId || '',
        departmentName: memberItem.dept || '',
        unitId: memberItem.unitId || '',
        unitName: memberItem.unit || '',
        signType: 'ElectronicSign',
        fileId: ''
      }
    })
  }
  ticketDetail.SGTeamMembersSignIn1 = ticketDetail.SGTeamMembersSignIn
  ticketDetail.workingControllerName = allData.workingControllerName
  ticketDetail.workTicketCode = allData.workTicketCode

  return ticketDetail
}
